{% extends "../master_picture.html" %}

{% block header %}
    {% include "../header.html" %}
{% endblock %}

{% block page %}
    <h1>{{ settings.picture }}:</h1>
    <h3><a href="javascript:PicLensLite.start();">Slide show</a></h3>
    {% if admin %}
    <form class="form" action="/picture/new" method="post">
    <div class="button">
        <input name="new" value="[New]" type="submit" />
        <input name="nb_of_pictures" value="{{ nb_of_pictures }}" type="hidden" />
        <input name="size_key" value="{{ size.key }}" type="hidden" />
        <input name="language_key" value="{{ language.key }}" type="hidden" />
    </div>
    </form>
    <br />
    {% endif %}
    <form class="form" action="/picture" method="post">
    <div class="button">
            <div class="picture-filter">
            <b>{{ settings.author }}:</b>
            <select name="author_key">
                <option value="">All</option>
                {% for a in authors %}
                    {% ifequal a.key author.key %}
                        <option selected="selected" value="{{ a.key }}">
                            {{ a.last_name }} {{ a.first_name }}
                        </option>
                    {% else %}
                        <option value="{{ a.key }}">
                            {{ a.last_name }} {{ a.first_name }}
                        </option>
                    {% endifequal %}
                {% endfor %}
            </select> |

            <b>{{ settings.collection }}:</b>
            <select name="collection_key">
                <option value="">All</option>
                {% for c in collections %}
                    {% ifequal c.key collection.key %}
                        <option selected="selected" value="{{ c.key }}">
                            {{ c.title }}
                        </option>
                    {% else %}
                        <option value="{{ c.key }}">
                            {{ c.title }}
                        </option>
                    {% endifequal %}
                {% endfor %}
            </select> |

            <b>{{ settings.exposition }}:</b>
            <select name="exposition_key">
                <option value="">All</option>
                {% for e in expositions %}
                    {% ifequal e.key exposition.key %}
                        <option selected="selected" value="{{ e.key }}">
                            {{ e.title }}
                        </option>
                    {% else %}
                        <option value="{{ e.key }}">
                            {{ e.title }}
                        </option>
                    {% endifequal %}
                {% endfor %}
            </select> |

            <select name="nb_of_pictures">
                {% for nb_of_p in all_nb_of_pictures %}
                    {% ifequal nb_of_p.value nb_of_pictures %}
                        <option selected="selected" value="{{ nb_of_p.value }}">
                            {{ nb_of_p.name }}
                        </option>
                    {% else %}
                        <option value="{{ nb_of_p.value }}">
                            {{ nb_of_p.name }}
                        </option>
                    {% endifequal %}
                {% endfor %}
            </select> |
            <input class="button" name="show" value="ok" type="submit" />
            <input name="nb_of_pictures" value="{{ nb_of_pictures }}" type="hidden" />
            <input name="size_key" value="{{ size.key }}" type="hidden" />
            <input name="language_key" value="{{ language.key }}" type="hidden" />
        </div>
    </div>
    </form>
    {% if links %}
    <center>
    <div class="picture-links">
        <table>
            <tr>
                {% for link in links %}
                <td>
                    {% if link.input %}
                    <form class="form" action="/picture" method="post">
                    <div class="button">
                        <input class="button" name="show" value="{{ link.id }}" type="submit" />
                        <input name="author_key" value="{{ author.key }}" type="hidden" />
                        <input name="collection_key" value="{{ collection.key }}" type="hidden" />
                        <input name="exposition_key" value="{{ exposition.key }}" type="hidden" />
                        <input name="offset" value="{{ link.offset }}" type="hidden" />
                        <input name="nb_of_pictures" value="{{ nb_of_pictures }}" type="hidden" />
                        <input name="size_key" value="{{ size.key }}" type="hidden" />
                        <input name="language_key" value="{{ language.key }}" type="hidden" />
                    </div>
                    </form>
                    {% else %}
                        {{ link.id }}
                    {% endif %}
                </td>
            {% endfor %}
            </tr>
        </table>
    </div>
    </center>
    {% endif %}
    <center>
    <div class="picture">
        <table>
        {% for raw in pictures %}
        <tr>
        {% for picture in raw %}
        <td>
        <table>
            <tr>
                <th colspan="2">
                    <img src="/img?url={{ picture.url }}&amp;size={{ size.width }}&amp;nb_of_pictures={{ nb_of_pictures }}" alt="{{ picture.url }}" />
                    <h3>{{ picture.title }}</h3>
                </th>
            </tr>
            {% if picture.author %}
            {% ifnotequal picture.author.last_name ' ' %}
            <tr>
                <td class="name">
                    <b>{{ settings.author }}:</b>
                </td>
                <td class="value">{{ picture.author.last_name }} {{ picture.author.first_name }}</td>
            </tr>
            {% endifnotequal %}
            {% endif %}
            {% if picture.collection %}
            {% ifnotequal picture.collection.title ' ' %}
            <tr>
                <td class="name">
                    <b>{{ settings.collection }}:</b>
                </td>
                <td class="value">{{ picture.collection.title }}</td>
            </tr>
            {% endifnotequal %}
            {% endif %}
            {% if picture.exposition %}
            {% ifnotequal picture.exposition.title ' ' %}
            <tr>
                <td class="name">
                    <b>{{ settings.exposition }}:</b>
                </td>
                <td class="value">
                    <form class="form" action="/exposition" method="post">
                    <div class="button">
                        <input name="show" value="{{ picture.exposition.title }}" type="submit" />
                        <input name="exposition_key" value="{{ picture.exposition.key }}" type="hidden" />
                        <input name="nb_of_pictures" value="{{ nb_of_pictures }}" type="hidden" />
                        <input name="size_key" value="{{ size.key }}" type="hidden" />
                        <input name="language_key" value="{{ language.key }}" type="hidden" />
                    </div>
                    </form>
                </td>
            </tr>
            {% endifnotequal %}
            {% endif %}
            <tr>
                <td colspan="2">{{ picture.html_info }}</td>
            </tr>
        </table>
        <center>
            {% if admin %}
            <form class="form" action="/picture/edit" method="post">
            <div class="button">
                <input name="edit" value="[Edit]" type="submit" />
                <input name="picture_key" value="{{ picture.key }}" type="hidden" />
                <input name="nb_of_pictures" value="{{ nb_of_pictures }}" type="hidden" />
                <input name="size_key" value="{{ size.key }}" type="hidden" />
                <input name="language_key" value="{{ language.key }}" type="hidden" />
            </div>
            </form>
            {% endif %}
        </center>
        </td>
        {% endfor %}
        </tr>
        {% endfor %}
        </table>
    </div>
    </center>
    {% if links %}
    <center>
    <div class="picture-links">
        <table>
            <tr>
                {% for link in links %}
                <td>
                    {% if link.input %}
                    <form class="form" action="/picture" method="post">
                    <div class="button">
                        <input class="button" name="show" value="{{ link.id }}" type="submit" />
                        <input name="author_key" value="{{ author.key }}" type="hidden" />
                        <input name="collection_key" value="{{ collection.key }}" type="hidden" />
                        <input name="offset" value="{{ link.offset }}" type="hidden" />
                        <input name="nb_of_pictures" value="{{ nb_of_pictures }}" type="hidden" />
                        <input name="size_key" value="{{ size.key }}" type="hidden" />
                        <input name="language_key" value="{{ language.key }}" type="hidden" />
                    </div>
                    </form>
                    {% else %}
                        {{ link.id }}
                    {% endif %}
                </td>
                {% endfor %}
            </tr>
        </table>
    </div>
    </center>
    {% endif %}
{% endblock %}

{% block footer %}
    {% include "../footer.html" %}
{% endblock %}
